package com.aionengine.gameserver.network.aion.clientpackets;

import com.aionengine.gameserver.model.gameobjects.player.Player;
import com.aionengine.gameserver.network.aion.AionClientPacket;
import com.aionengine.gameserver.network.aion.AionConnection.State;
import com.aionengine.gameserver.network.aion.serverpackets.SM_CHAT_WINDOW;
import com.aionengine.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE;
import com.aionengine.gameserver.utils.PacketSendUtility;
import com.aionengine.gameserver.world.World;

/**
 * @author ginho1
 */
public class CM_CHAT_GROUP_INFO extends AionClientPacket {

    private String playerName;
    @SuppressWarnings("unused")
    private int unk;

    public CM_CHAT_GROUP_INFO(int opcode, State state, State... restStates) {
        super(opcode, state, restStates);
    }

    @Override
    protected void readImpl() {
        playerName = readS();
        unk = readD();
    }

    @Override
    protected void runImpl() {
        Player player = getConnection().getActivePlayer();
        Player target = World.getInstance().findPlayer(playerName);
        if (target == null) {
            PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MSG_ASK_PCINFO_LOGOFF);
            return;
        }
        PacketSendUtility.sendPacket(player, new SM_CHAT_WINDOW(target, true));
    }
}